{% extends 'layout.html' %}
{% block body %}
    <h2>SDN控制器管理</h2>
{#    <li><h3>Host列表</h3></li>#}
{#    <ul class=hosts>#}
{#        {% if hosts %}#}
{#            {% for (index,host) in enumerate(hosts) %}#}
{#                <li class={{ 'li'+str(index) }}>#}
{#                    <input type="checkbox" class={{ 'cb'+str(index) }}>#}
{#                    <b>Host id: {{ host['id'] }}</b><br>#}
{#                    </input>#}
{#                    Mac Address: {{ host['mac'] }} <br>#}
{#                    Ip Address: {{ host['ipAddresses'][0] }}#}
{##}
{#                    <script>#}
{#                        $(document).ready(function () {#}
{#                            $(".{{ 'cb'+str(index) }}").click(function () {#}
{#                                if ($(this).is(":checked")) {#}
{#                                    $(".{{ 'li'+str(index) }}").hide(500);#}
{#                                    var before_text = $("#mac_address").val()#}
{#                                    $("#mac_address").val(before_text + " | {{ host['mac'] }}");#}
{#                                }#}
{#                            })#}
{#                        });#}
{#                    </script>#}
{##}
{#                    {% else %}#}
{#                </li>#}
{#                <em>目前无host在工作</em>#}
{#            {% endfor %}#}
{#        {% else %}#}
{#            <b>请检查与控制器的通信状况</b>#}
{#        {% endif %}#}
{#    </ul>#}
{##}
{#    <hr>#}
{#    <li><h3>SDN管理</h3></li>#}
{##}
{#    <p>命令</p>#}
{##}
{#    <select name="options" class="commend">#}
{#        <option value="back_this_hosts">将以上所选主机加入黑名单</option>#}
{#        <option value="back_this_hosts">将以上所选主机移除黑名单</option>#}
{#    </select>#}
{##}
{#    <script>#}
{#        $(document).ready(function () {#}
{#            $(".commend").change(function () {#}
{#                var op = $(this).get(0).selectedIndex#}
{#                if (op == 0) {#}
{#                    $(".black-list").attr("action", "{{ url_for('block_host_by_mac') }}")#}
{#                }#}
{#                if (op == 1) {#}
{#                    $(".black-list").attr("action", "{{ url_for('remove_host_by_mac') }}")#}
{#                }#}
{#            })#}
{#        });#}
{#    </script>#}
{##}
{#    <br>#}
{#    <br>#}
{#    <form action="{{ url_for('block_host_by_mac') }}" method="post" class="black-list">#}
{#        {{ form.hidden_tag() }}#}
{#        已选地址列表：#}
{#        {{ form.mac_address(readonly=true, id = "mac_address") }}#}
{#        <input class="black_hosts" type=submit value=执行>#}
{#    </form>#}
{#    </hr>#}
{##}
{#    <hr>#}
    <li><h3>路径验证</h3></li>
    <form action="{{ url_for('verify_route') }}" method="post" class="verify-route">
        {{ form1.hidden_tag() }}
        起始地址：{{ form1.src_host }}
        目的地址：{{ form1.dst_host }}
        <input class="black_hosts" type=submit value=验证>
{#        <p id='test'></p>#}
{#        <!--<p id='tmp'>{{form1.src_host}}</p>-->#}
{#        <script>#}
{#          var D;#}
{#          document.getElementById("test").innerHTML=D+"shit";#}
{#        </script>#}
        <p>{{ route }} </p>
        <div>
          <img id="pic" src= {{url_for('static',filename='pics/0.png',_external=True)}} width="523" height="271">
        </div>
        {% if route %}

        <script>
{#            var p="{{url_for('static',filename='pics/12_" + route + ".png',_external=True)}}";#}
{#            var p="{{url_for('static',filename='pics/12_"+{{ route }}+".png',_external=True)}}";#}
            var tp={{ route }};

            var p={{url_for('static',filename='pics/12_124.png',_external=True)}};
            alert(p);
{#            var p="{{url_for(" + "'" + "static" + "'" + ",filename=" + "'" + "pics/12_" + tp + ".png" +#}
{#            "'" + ",_external=True)}}";#}

            alert(p);
{#            alert(document.getElementById("pic").src);#}
            document.getElementById("pic").src=p;
{#            alert(document.getElementById("pic").src);#}
        </script>
        {% endif %}



    </form>
    
{#        <script>#}
{#          function ChooseOK(){ #}
{#          //var H,D;#}
{#	  //H=document.getElementById("Hnum").value;#}
{#	  //D=docment.getElementById("form1.src_host").value;#}
{#          alert("123123");#}
{#	  document.getElementById("test").innerHTML={{ route }}+"shit";#}
{#	  var p="{{url_for('static',filename='pics/12_"+{{ route }}+".png',_external=True)}}";#}
{#          alert(p);#}
{#	  alert(document.getElementById("pic").src);#}
{#	  document.getElementById("pic").src=p;#}
{#	  alert(document.getElementById("pic").src);#}
{#          //$("#pic").attr("src",p);#}
{#	  }#}
{#        </script>#}

    </hr>
{% endblock %}
